<?php
use Yii\helpers\Html;
use yii\widgets\LinkPager;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
$this->title = '积分管理';
$session = Yii::$app->session;
?>
<div class="container">
    <div class="row">
      
       
        <?php echo $this->render('_leftnav') ?>
        <div class="col-md-10">
          <div class="page-header clearfix">
            <h1 class="pull-left">积分账单</h1>
            <div class="pull-right">

                                            
            </div>
          </div>
          <?php
	$form = ActiveForm::begin([
	'action' => ['coin/virtual'],
	'method'=>'post',
	'options' => [
					'class'=>'form-inline well well-sm',
	                'id' => 'coin-orders-search-form'
				 ]	
		]);	
	?> 
        <div class="form-group"> 
           <?=Html::dropDownList('type',$session->get('virtual_status')?$session->get('virtual_status'):0, ArrayHelper::map(['全部记录','充值记录','消费记录'],'id', 'customer_name'), ['class' => 'form-control']);?>         
        </div> 
        <div class="form-group"> 
          <?=Html::dropDownList('createdtime',$session->get('virtual_addtime')?$session->get('virtual_addtime'):0, ArrayHelper::map(['全部记录',strtotime('-1 week last monday')=>'最近一周',strtotime(date("Y-m-01",strtotime("-1 month")))=>'最近一个月',strtotime(date("Y-m-01",strtotime("-3 month")))=>'最近三个月'],'id', 'customer_name'), ['class' => 'form-control']);?> 
        </div> 
        <div class="form-group">
             <?=Html::dropDownList('keywordtype',$session->get('keyword')?$session->get('keyword'):'notl', ArrayHelper::map(['notl'=>'--选择类型--','virtual_serial'=>'流水号','username'=>'用户名'],'id', 'customer_name'), ['class' => 'form-control']);?> 
        </div>
        <div class="form-group">
            <?= Html::input('text', 'username',$session->get('keywordname')?$session->get('keywordname'):'', ['class' => 'form-control','placeholder'=>'关键词']) ?>            
        </div>
      <?= Html::submitButton('搜索', ['class'=>'btn btn-primary']) ?>
      <a class="btn btn-primary" href="<?=Url::toRoute(['coin/virtual', 'del' =>1]);?>">清空条件</a>
      <a class="btn btn-primary" href="<?=Url::toRoute(['coin/export']);?>">导出结果</a>
    <?php ActiveForm::end(); ?>    
    <script>
		function Export(data){
			alert(data);
		}
    </script>
    <div class="table-responsive">
      <table class="table table-striped">
        <tbody>
        <tr>
          <th>流水号</th>
          <th>用户名</th>
          <th>积分量</th>          
          <th>充值/消费</th>
          <th>成交时间</th>
          <th>简述</th>
        </tr>
        <?php foreach($lists as $key=>$val):?>
<tr id="article-<?=Html::encode($val['virtual_id'])?>" align='left'>
	
	<td>
		<span class="text-muted">
			<b><?=Html::encode($val['virtual_serial'])?></b>
		</span>
	</td>
	<td>
		<span class="text-muted">
			<b><?=Html::encode($val['username'])?></b>
		</span>
	</td>
	<td>
		<span class="text-muted">
			<b><?=Html::encode($val['virtual_num'])?></b>/积分
		</span>
	</td>
	<td>
	   <?php if($val['virtual_status']==1){ ?>
	   <font color='green'>+充值</font>
	   <?php }else if($val['virtual_status']==2){ ?>
	   <font color='red'>-消费</font>
	   <?php } ?>
	</td>
	<td>
		<b><?=date('Y-m-d H:i:s',$val['virtual_addtime']);?></b>
	</td>

	<td>
		<span class="text-success" title='<?=Html::encode($val['vartual_detail'])?>'><?=Html::encode($val['vartual_info']);?></span>
	</td>

<!-- 	<td> -->
<!-- 		<div class="btn-group">
		  <a href="" class="btn btn-default btn-sm">编辑</a> -->
<!-- 		  <a href="#" type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> -->
<!-- 		    <span class="caret"></span> -->
<!-- 		  </a> -->
<!-- 		  <ul class="dropdown-menu"> -->
<!-- 		  		     				    <li><a href="javascript:" data-role="unpublish-item" data-url="/admin/article/12/unpublish">取消发布</a></li> -->
<!-- 		    		    			    <li><a href="javascript:" data-role="trash-item" data-url="/admin/article/12/trash">移至回收站</a></li> -->
<!-- 		    		    		  </ul> -->
<!-- 			</div> -->
<!-- 		</td> -->
	</tr>
<?php endforeach; ?>	
      </tbody>
      </table>
       <div style=' margin-left:38%;'>
	 <?= LinkPager::widget(['pagination' => $pages]); ?>
	 </div>
    </div>
        </div>
          </div>
  </div>